<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.4.0">


  <link rel="apple-touch-icon" sizes="180x180" href="/images/shianfeng.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/shianfeng.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/shianfeng.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">



<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.15.3/css/all.min.css">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/animate.css@3.1.1/animate.min.css">

<script class="next-config" data-name="main" type="application/json">{&quot;hostname&quot;:&quot;example.com&quot;,&quot;root&quot;:&quot;&#x2F;&quot;,&quot;images&quot;:&quot;&#x2F;images&quot;,&quot;scheme&quot;:&quot;Gemini&quot;,&quot;version&quot;:&quot;8.3.0&quot;,&quot;exturl&quot;:false,&quot;sidebar&quot;:{&quot;position&quot;:&quot;left&quot;,&quot;display&quot;:&quot;post&quot;,&quot;padding&quot;:18,&quot;offset&quot;:12},&quot;copycode&quot;:false,&quot;bookmark&quot;:{&quot;enable&quot;:false,&quot;color&quot;:&quot;#222&quot;,&quot;save&quot;:&quot;auto&quot;},&quot;fancybox&quot;:false,&quot;mediumzoom&quot;:false,&quot;lazyload&quot;:false,&quot;pangu&quot;:false,&quot;comments&quot;:{&quot;style&quot;:&quot;tabs&quot;,&quot;active&quot;:null,&quot;storage&quot;:true,&quot;lazyload&quot;:false,&quot;nav&quot;:null},&quot;motion&quot;:{&quot;enable&quot;:true,&quot;async&quot;:false,&quot;transition&quot;:{&quot;post_block&quot;:&quot;fadeIn&quot;,&quot;post_header&quot;:&quot;fadeInDown&quot;,&quot;post_body&quot;:&quot;fadeInDown&quot;,&quot;coll_header&quot;:&quot;fadeInLeft&quot;,&quot;sidebar&quot;:&quot;fadeInUp&quot;}},&quot;prism&quot;:false,&quot;i18n&quot;:{&quot;placeholder&quot;:&quot;搜索...&quot;,&quot;empty&quot;:&quot;没有找到任何搜索结果：${query}&quot;,&quot;hits_time&quot;:&quot;找到 ${hits} 个搜索结果（用时 ${time} 毫秒）&quot;,&quot;hits&quot;:&quot;找到 ${hits} 个搜索结果&quot;}}</script>
<meta name="description" content="基本命令123456789101112131415161718192021222324uname -m 显示机器的处理器架构  uname -r 显示正在使用的内核版本  dmidecode -q 显示硬件系统部件  (SMBIOS &#x2F; DMI) hdparm -i &#x2F;dev&#x2F;hda 罗列一个磁盘的架构特性  hdparm -tT &#x2F;dev&#x2F;sda">
<meta property="og:type" content="article">
<meta property="og:title" content="Linux 常用命令">
<meta property="og:url" content="http://example.com/2021/06/15/Linux-%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4/index.html">
<meta property="og:site_name" content="Mr.Shianfeng">
<meta property="og:description" content="基本命令123456789101112131415161718192021222324uname -m 显示机器的处理器架构  uname -r 显示正在使用的内核版本  dmidecode -q 显示硬件系统部件  (SMBIOS &#x2F; DMI) hdparm -i &#x2F;dev&#x2F;hda 罗列一个磁盘的架构特性  hdparm -tT &#x2F;dev&#x2F;sda">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="http://example.com/2021/06/15/Linux-%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4/DSC_0174.JPG">
<meta property="article:published_time" content="2021-06-15T07:16:23.000Z">
<meta property="article:modified_time" content="2021-06-15T08:45:44.819Z">
<meta property="article:author" content="冰冷的火焰">
<meta property="article:tag" content="Linux">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="http://example.com/2021/06/15/Linux-%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4/DSC_0174.JPG">


<link rel="canonical" href="http://example.com/2021/06/15/Linux-%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4/">



<script class="next-config" data-name="page" type="application/json">{&quot;sidebar&quot;:&quot;&quot;,&quot;isHome&quot;:false,&quot;isPost&quot;:true,&quot;lang&quot;:&quot;zh-CN&quot;,&quot;comments&quot;:true,&quot;permalink&quot;:&quot;http:&#x2F;&#x2F;example.com&#x2F;2021&#x2F;06&#x2F;15&#x2F;Linux-%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4&#x2F;&quot;,&quot;path&quot;:&quot;2021&#x2F;06&#x2F;15&#x2F;Linux-常用命令&#x2F;&quot;,&quot;title&quot;:&quot;Linux 常用命令&quot;}</script>

<script class="next-config" data-name="calendar" type="application/json">&quot;&quot;</script>
<title>Linux 常用命令 | Mr.Shianfeng</title><script src="/js/config.js"></script>
  




  <noscript>
    <link rel="stylesheet" href="/css/noscript.css">
  </noscript>
</head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏" role="button">
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <i class="logo-line"></i>
      <h1 class="site-title">Mr.Shianfeng</h1>
      <i class="logo-line"></i>
    </a>
      <p class="site-subtitle" itemprop="description">xxxxxxxx</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>



<nav class="site-nav">
  <ul class="main-menu menu">
        <li class="menu-item menu-item-home"><a href="/" rel="section">首页</a></li>
        <li class="menu-item menu-item-tags"><a href="/tags" rel="section">标签<span class="badge">3</span></a></li>
        <li class="menu-item menu-item-categories"><a href="/categories" rel="section">分类<span class="badge">3</span></a></li>
        <li class="menu-item menu-item-archives"><a href="/archives" rel="section">归档<span class="badge">3</span></a></li>
        <li class="menu-item menu-item-about"><a href="/about" rel="section">关于</a></li>
  </ul>
</nav>




</div>
        
  
  <div class="toggle sidebar-toggle" role="button">
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
  </div>

  <aside class="sidebar">

    <div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
            <div class="post-toc animated"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%9F%BA%E6%9C%AC%E5%91%BD%E4%BB%A4"><span class="nav-number">1.</span> <span class="nav-text">基本命令</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%85%B3%E6%9C%BA-%E7%B3%BB%E7%BB%9F%E7%9A%84%E5%85%B3%E6%9C%BA%E3%80%81%E9%87%8D%E5%90%AF%E4%BB%A5%E5%8F%8A%E7%99%BB%E5%87%BA"><span class="nav-number">2.</span> <span class="nav-text">关机 (系统的关机、重启以及登出 )</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%96%87%E4%BB%B6%E5%92%8C%E7%9B%AE%E5%BD%95"><span class="nav-number">3.</span> <span class="nav-text">文件和目录</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%96%87%E4%BB%B6%E6%90%9C%E7%B4%A2"><span class="nav-number">4.</span> <span class="nav-text">文件搜索</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%8C%82%E8%BD%BD%E4%B8%80%E4%B8%AA%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F"><span class="nav-number">5.</span> <span class="nav-text">挂载一个文件系统</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E7%A3%81%E7%9B%98%E7%A9%BA%E9%97%B4"><span class="nav-number">6.</span> <span class="nav-text">磁盘空间</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E7%94%A8%E6%88%B7%E5%92%8C%E7%BE%A4%E7%BB%84"><span class="nav-number">7.</span> <span class="nav-text">用户和群组</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%96%87%E4%BB%B6%E7%9A%84%E6%9D%83%E9%99%90-%E4%BD%BF%E7%94%A8-%E2%80%9C-%E2%80%9D-%E8%AE%BE%E7%BD%AE%E6%9D%83%E9%99%90%EF%BC%8C%E4%BD%BF%E7%94%A8-%E2%80%9C-%E2%80%9D-%E7%94%A8%E4%BA%8E%E5%8F%96%E6%B6%88"><span class="nav-number">8.</span> <span class="nav-text">文件的权限 - 使用 “+” 设置权限，使用 “-” 用于取消</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%96%87%E4%BB%B6%E7%9A%84%E7%89%B9%E6%AE%8A%E5%B1%9E%E6%80%A7-%E4%BD%BF%E7%94%A8-%E2%80%9C-%E2%80%9D-%E8%AE%BE%E7%BD%AE%E6%9D%83%E9%99%90%EF%BC%8C%E4%BD%BF%E7%94%A8-%E2%80%9C-%E2%80%9D-%E7%94%A8%E4%BA%8E%E5%8F%96%E6%B6%88"><span class="nav-number">9.</span> <span class="nav-text">文件的特殊属性 - 使用 “+” 设置权限，使用 “-” 用于取消</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%89%93%E5%8C%85%E5%92%8C%E5%8E%8B%E7%BC%A9%E6%96%87%E4%BB%B6"><span class="nav-number">10.</span> <span class="nav-text">打包和压缩文件</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#RPM-%E5%8C%85-%EF%BC%88Fedora-Redhat%E5%8F%8A%E7%B1%BB%E4%BC%BC%E7%B3%BB%E7%BB%9F%EF%BC%89"><span class="nav-number">11.</span> <span class="nav-text">RPM 包 - （Fedora, Redhat及类似系统）</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#YUM-%E8%BD%AF%E4%BB%B6%E5%8C%85%E5%8D%87%E7%BA%A7%E5%99%A8-%EF%BC%88Fedora-RedHat%E5%8F%8A%E7%B1%BB%E4%BC%BC%E7%B3%BB%E7%BB%9F%EF%BC%89"><span class="nav-number">12.</span> <span class="nav-text">YUM 软件包升级器 - （Fedora, RedHat及类似系统）</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#DEB-%E5%8C%85-Debian-Ubuntu-%E4%BB%A5%E5%8F%8A%E7%B1%BB%E4%BC%BC%E7%B3%BB%E7%BB%9F"><span class="nav-number">13.</span> <span class="nav-text">DEB 包 (Debian, Ubuntu 以及类似系统)</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%9F%A5%E7%9C%8B%E6%96%87%E4%BB%B6%E5%86%85%E5%AE%B9"><span class="nav-number">14.</span> <span class="nav-text">查看文件内容</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%96%87%E6%9C%AC%E5%A4%84%E7%90%86"><span class="nav-number">15.</span> <span class="nav-text">文本处理</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%AD%97%E7%AC%A6%E8%AE%BE%E7%BD%AE%E5%92%8C%E6%96%87%E4%BB%B6%E6%A0%BC%E5%BC%8F%E8%BD%AC%E6%8D%A2"><span class="nav-number">16.</span> <span class="nav-text">字符设置和文件格式转换</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F%E5%88%86%E6%9E%90"><span class="nav-number">17.</span> <span class="nav-text">文件系统分析</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%88%9D%E5%A7%8B%E5%8C%96%E4%B8%80%E4%B8%AA%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F"><span class="nav-number">18.</span> <span class="nav-text">初始化一个文件系统</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#SWAP%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F"><span class="nav-number">19.</span> <span class="nav-text">SWAP文件系统</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%A4%87%E4%BB%BD"><span class="nav-number">20.</span> <span class="nav-text">备份</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E7%BD%91%E7%BB%9C-%EF%BC%88%E4%BB%A5%E5%A4%AA%E7%BD%91%E5%92%8CWIFI%E6%97%A0%E7%BA%BF%EF%BC%89"><span class="nav-number">21.</span> <span class="nav-text">网络 - （以太网和WIFI无线）</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%88%97%E5%87%BA%E7%9B%AE%E5%BD%95%E5%86%85%E5%AE%B9"><span class="nav-number">22.</span> <span class="nav-text">列出目录内容</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%9F%A5%E7%9C%8B%E6%96%87%E4%BB%B6%E7%9A%84%E7%B1%BB%E5%9E%8B"><span class="nav-number">23.</span> <span class="nav-text">查看文件的类型</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%A4%8D%E5%88%B6%E6%96%87%E4%BB%B6%E7%9B%AE%E5%BD%95"><span class="nav-number">24.</span> <span class="nav-text">复制文件目录</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E7%B3%BB%E7%BB%9F%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4"><span class="nav-number">25.</span> <span class="nav-text">系统常用命令</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#VIM"><span class="nav-number">26.</span> <span class="nav-text">VIM</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E8%BD%AF%E4%BB%B6%E5%8C%85%E7%AE%A1%E7%90%86%E5%91%BD%E4%BB%A4-RPM"><span class="nav-number">27.</span> <span class="nav-text">软件包管理命令(RPM)</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Linux-Command"><span class="nav-number">28.</span> <span class="nav-text">Linux Command</span></a></li></ol></div>
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-author site-overview-item animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="冰冷的火焰"
      src="/images/shianfeng.png">
  <p class="site-author-name" itemprop="name">冰冷的火焰</p>
  <div class="site-description" itemprop="description">什么天赋异禀，都得翻山越岭</div>
</div>
<div class="site-state-wrap site-overview-item animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives">
        
          <span class="site-state-item-count">3</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories">
          
        <span class="site-state-item-count">3</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags">
          
        <span class="site-state-item-count">3</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author site-overview-item animated">
      <span class="links-of-author-item">
        <a href="https://github.com/yourname" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;yourname" rel="noopener" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
      <span class="links-of-author-item">
        <a href="mailto:yourname@gmail.com" title="E-Mail → mailto:yourname@gmail.com" rel="noopener" target="_blank"><i class="fa fa-envelope fa-fw"></i>E-Mail</a>
      </span>
  </div>



        </div>
      </div>
    </div>
  </aside>
  <div class="sidebar-dimmer"></div>


    </header>

    
  <div class="back-to-top" role="button" aria-label="返回顶部">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


    <div class="main-inner post posts-expand">


  


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/06/15/Linux-%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/shianfeng.png">
      <meta itemprop="name" content="冰冷的火焰">
      <meta itemprop="description" content="什么天赋异禀，都得翻山越岭">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Mr.Shianfeng">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          Linux 常用命令
        </h1>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>
      

      <time title="创建时间：2021-06-15 15:16:23 / 修改时间：16:45:44" itemprop="dateCreated datePublished" datetime="2021-06-15T15:16:23+08:00">2021-06-15</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F/" itemprop="url" rel="index"><span itemprop="name">操作系统</span></a>
        </span>
    </span>

  
    <span class="post-meta-item" title="阅读次数" id="busuanzi_container_page_pv">
      <span class="post-meta-item-icon">
        <i class="far fa-eye"></i>
      </span>
      <span class="post-meta-item-text">阅读次数：</span>
      <span id="busuanzi_value_page_pv"></span>
    </span>
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
        <h2 id="基本命令"><a href="#基本命令" class="headerlink" title="基本命令"></a>基本命令</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line">uname -m 显示机器的处理器架构  </span><br><span class="line">uname -r 显示正在使用的内核版本  </span><br><span class="line">dmidecode -q 显示硬件系统部件  </span><br><span class="line">(SMBIOS &#x2F; DMI) hdparm -i &#x2F;dev&#x2F;hda 罗列一个磁盘的架构特性  </span><br><span class="line">hdparm -tT &#x2F;dev&#x2F;sda 在磁盘上执行测试性读取操作系统信息  </span><br><span class="line">arch 显示机器的处理器架构  </span><br><span class="line">uname -m 显示机器的处理器架构  </span><br><span class="line">uname -r 显示正在使用的内核版本  </span><br><span class="line">dmidecode -q 显示硬件系统部件 - (SMBIOS &#x2F; DMI)  </span><br><span class="line">hdparm -i &#x2F;dev&#x2F;hda 罗列一个磁盘的架构特性  </span><br><span class="line">hdparm -tT &#x2F;dev&#x2F;sda 在磁盘上执行测试性读取操作  </span><br><span class="line">cat &#x2F;proc&#x2F;cpuinfo 显示CPU info的信息  </span><br><span class="line">cat &#x2F;proc&#x2F;interrupts 显示中断  </span><br><span class="line">cat &#x2F;proc&#x2F;meminfo 校验内存使用  </span><br><span class="line">cat &#x2F;proc&#x2F;swaps 显示哪些swap被使用  </span><br><span class="line">cat &#x2F;proc&#x2F;version 显示内核的版本  </span><br><span class="line">cat &#x2F;proc&#x2F;net&#x2F;dev 显示网络适配器及统计  </span><br><span class="line">cat &#x2F;proc&#x2F;mounts 显示已加载的文件系统  </span><br><span class="line">lspci -tv 罗列 PCI 设备  </span><br><span class="line">lsusb -tv 显示 USB 设备  </span><br><span class="line">date 显示系统日期  </span><br><span class="line">cal 2007 显示2007年的日历表  </span><br><span class="line">date 041217002007.00 设置日期和时间 - 月日时分年.秒  </span><br><span class="line">clock -w 将时间修改保存到 BIOS  </span><br></pre></td></tr></table></figure>
<h2 id="关机-系统的关机、重启以及登出"><a href="#关机-系统的关机、重启以及登出" class="headerlink" title="关机 (系统的关机、重启以及登出 )"></a>关机 (系统的关机、重启以及登出 )</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">shutdown -h now 关闭系统(1)  </span><br><span class="line">init 0 关闭系统(2)  </span><br><span class="line">telinit 0 关闭系统(3)  </span><br><span class="line">shutdown -h hours:minutes &amp; 按预定时间关闭系统  </span><br><span class="line">shutdown -c 取消按预定时间关闭系统  </span><br><span class="line">shutdown -r now 重启(1)  </span><br><span class="line">reboot 重启(2)  </span><br><span class="line">logout 注销  </span><br></pre></td></tr></table></figure>
<h2 id="文件和目录"><a href="#文件和目录" class="headerlink" title="文件和目录"></a>文件和目录</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br></pre></td><td class="code"><pre><span class="line">cd &#x2F;home 进入 &#39;&#x2F; home&#39; 目录&#39;</span><br><span class="line">cd .. 返回上一级目录</span><br><span class="line">cd ..&#x2F;.. 返回上两级目录</span><br><span class="line">cd 进入个人的主目录</span><br><span class="line">cd ~user1 进入个人的主目录</span><br><span class="line">cd - 返回上次所在的目录</span><br><span class="line">pwd 显示工作路径</span><br><span class="line">ls 查看目录中的文件</span><br><span class="line">ls -F 查看目录中的文件</span><br><span class="line">ls -l 显示文件和目录的详细资料</span><br><span class="line">ls -a 显示隐藏文件</span><br><span class="line">ls *[0-9]* 显示包含数字的文件名和目录名</span><br><span class="line">tree 显示文件和目录由根目录开始的树形结构(1)</span><br><span class="line">lstree 显示文件和目录由根目录开始的树形结构(2)</span><br><span class="line">mkdir dir1 创建一个叫做 &#39;dir1&#39; 的目录&#39;</span><br><span class="line">mkdir dir1 dir2 同时创建两个目录</span><br><span class="line">mkdir -p &#x2F;tmp&#x2F;dir1&#x2F;dir2 创建一个目录树</span><br><span class="line">rm -f file1 删除一个叫做 &#39;file1&#39; 的文件&#39;</span><br><span class="line">rmdir dir1 删除一个叫做 &#39;dir1&#39; 的目录&#39;</span><br><span class="line">rm -rf dir1 删除一个叫做 &#39;dir1&#39; 的目录并同时删除其内容</span><br><span class="line">rm -rf dir1 dir2 同时删除两个目录及它们的内容</span><br><span class="line">mv dir1 new_dir 重命名&#x2F;移动 一个目录</span><br><span class="line">cp file1 file2 复制一个文件</span><br><span class="line">cp dir&#x2F;* . 复制一个目录下的所有文件到当前工作目录</span><br><span class="line">cp -a &#x2F;tmp&#x2F;dir1 . 复制一个目录到当前工作目录</span><br><span class="line">cp -a dir1 dir2 复制一个目录</span><br><span class="line">ln -s file1 lnk1 创建一个指向文件或目录的软链接</span><br><span class="line">ln file1 lnk1 创建一个指向文件或目录的物理链接</span><br><span class="line">touch -t 0712250000 file1 修改一个文件或目录的时间戳 - (YYMMDDhhmm)</span><br><span class="line">file file1 outputs the mime type of the file as text</span><br><span class="line">iconv -l 列出已知的编码</span><br><span class="line">iconv -f fromEncoding -t toEncoding inputFile &gt; outputFile creates a new from the given input file by assuming it is encoded in fromEncoding and converting it to toEncoding.</span><br><span class="line">find . -maxdepth 1 -name *.jpg -print -exec convert &quot;&#123;&#125;&quot; -resize 80x60 &quot;thumbs&#x2F;&#123;&#125;&quot; \; batch resize files in the current directory and send them to a thumbnails directory (requires convert from Imagemagick)</span><br></pre></td></tr></table></figure>
<h2 id="文件搜索"><a href="#文件搜索" class="headerlink" title="文件搜索"></a>文件搜索</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">find &#x2F; -name file1 从 &#39;&#x2F;&#39; 开始进入根文件系统搜索文件和目录</span><br><span class="line">find &#x2F; -user user1 搜索属于用户 &#39;user1&#39; 的文件和目录</span><br><span class="line">find &#x2F;home&#x2F;user1 -name \*.bin 在目录 &#39;&#x2F; home&#x2F;user1&#39; 中搜索带有&#39;.bin&#39; 结尾的文件</span><br><span class="line">find &#x2F;usr&#x2F;bin -type f -atime +100 搜索在过去100天内未被使用过的执行文件</span><br><span class="line">find &#x2F;usr&#x2F;bin -type f -mtime -10 搜索在10天内被创建或者修改过的文件</span><br><span class="line">find &#x2F; -name \*.rpm -exec chmod 755 &#39;&#123;&#125;&#39; \; 搜索以 &#39;.rpm&#39; 结尾的文件并定义其权限</span><br><span class="line">find &#x2F; -xdev -name \*.rpm 搜索以 &#39;.rpm&#39; 结尾的文件，忽略光驱、捷盘等可移动设备</span><br><span class="line">locate \*.ps 寻找以 &#39;.ps&#39; 结尾的文件 - 先运行 &#39;updatedb&#39; 命令</span><br><span class="line">whereis halt 显示一个二进制文件、源码或man的位置</span><br><span class="line">which halt 显示一个二进制文件或可执行文件的完整路径</span><br></pre></td></tr></table></figure>
<h2 id="挂载一个文件系统"><a href="#挂载一个文件系统" class="headerlink" title="挂载一个文件系统"></a>挂载一个文件系统</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">mount &#x2F;dev&#x2F;hda2 &#x2F;mnt&#x2F;hda2 挂载一个叫做hda2的盘 - 确定目录 &#39;&#x2F; mnt&#x2F;hda2&#39; 已经存在</span><br><span class="line">umount &#x2F;dev&#x2F;hda2 卸载一个叫做hda2的盘 - 先从挂载点 &#39;&#x2F; mnt&#x2F;hda2&#39; 退出</span><br><span class="line">fuser -km &#x2F;mnt&#x2F;hda2 当设备繁忙时强制卸载</span><br><span class="line">umount -n &#x2F;mnt&#x2F;hda2 运行卸载操作而不写入 &#x2F;etc&#x2F;mtab 文件- 当文件为只读或当磁盘写满时非常有用</span><br><span class="line">mount &#x2F;dev&#x2F;fd0 &#x2F;mnt&#x2F;floppy 挂载一个软盘</span><br><span class="line">mount &#x2F;dev&#x2F;cdrom &#x2F;mnt&#x2F;cdrom 挂载一个cdrom或dvdrom</span><br><span class="line">mount &#x2F;dev&#x2F;hdc &#x2F;mnt&#x2F;cdrecorder 挂载一个cdrw或dvdrom</span><br><span class="line">mount &#x2F;dev&#x2F;hdb &#x2F;mnt&#x2F;cdrecorder 挂载一个cdrw或dvdrom</span><br><span class="line">mount -o loop file.iso &#x2F;mnt&#x2F;cdrom 挂载一个文件或ISO镜像文件</span><br><span class="line">mount -t vfat &#x2F;dev&#x2F;hda5 &#x2F;mnt&#x2F;hda5 挂载一个Windows FAT32文件系统</span><br><span class="line">mount &#x2F;dev&#x2F;sda1 &#x2F;mnt&#x2F;usbdisk 挂载一个usb 捷盘或闪存设备</span><br><span class="line">mount -t smbfs -o username&#x3D;user,password&#x3D;pass &#x2F;&#x2F;WinClient&#x2F;share &#x2F;mnt&#x2F;share 挂载一个windows网络共享</span><br></pre></td></tr></table></figure>
<h2 id="磁盘空间"><a href="#磁盘空间" class="headerlink" title="磁盘空间"></a>磁盘空间</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">df -h 显示已经挂载的分区列表</span><br><span class="line">ls -lSr |more 以尺寸大小排列文件和目录</span><br><span class="line">du -sh dir1 估算目录 &#39;dir1&#39; 已经使用的磁盘空间&#39;</span><br><span class="line">du -sk * | sort -rn 以容量大小为依据依次显示文件和目录的大小</span><br><span class="line">rpm -q -a --qf &#39;%10&#123;SIZE&#125;t%&#123;NAME&#125;n&#39; | sort -k1,1n 以大小为依据依次显示已安装的rpm包所使用的空间 (fedora, redhat类系统)</span><br><span class="line">dpkg-query -W -f&#x3D;&#39;$&#123;Installed-Size;10&#125;t$&#123;Package&#125;n&#39; | sort -k1,1n 以大小为依据显示已安装的deb包所使用的空间 (ubuntu, debian类系统)</span><br></pre></td></tr></table></figure>
<h2 id="用户和群组"><a href="#用户和群组" class="headerlink" title="用户和群组"></a>用户和群组</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">groupadd group_name 创建一个新用户组</span><br><span class="line">groupdel group_name 删除一个用户组</span><br><span class="line">groupmod -n new_group_name old_group_name 重命名一个用户组</span><br><span class="line">useradd -c &quot;Name Surname &quot; -g admin -d &#x2F;home&#x2F;user1 -s &#x2F;bin&#x2F;bash user1 创建一个属于 &quot;admin&quot; 用户组的用户</span><br><span class="line">useradd user1 创建一个新用户</span><br><span class="line">userdel -r user1 删除一个用户 ( &#39;-r&#39; 排除主目录)</span><br><span class="line">usermod -c &quot;User FTP&quot; -g system -d &#x2F;ftp&#x2F;user1 -s &#x2F;bin&#x2F;nologin user1 修改用户属性</span><br><span class="line">passwd 修改口令</span><br><span class="line">passwd user1 修改一个用户的口令 (只允许root执行)</span><br><span class="line">chage -E 2005-12-31 user1 设置用户口令的失效期限</span><br><span class="line">pwck 检查 &#39;&#x2F;etc&#x2F;passwd&#39; 的文件格式和语法修正以及存在的用户</span><br><span class="line">grpck 检查 &#39;&#x2F;etc&#x2F;passwd&#39; 的文件格式和语法修正以及存在的群组</span><br><span class="line">newgrp group_name 登陆进一个新的群组以改变新创建文件的预设群组</span><br></pre></td></tr></table></figure>
<h2 id="文件的权限-使用-“-”-设置权限，使用-“-”-用于取消"><a href="#文件的权限-使用-“-”-设置权限，使用-“-”-用于取消" class="headerlink" title="文件的权限 - 使用 “+” 设置权限，使用 “-” 用于取消"></a>文件的权限 - 使用 “+” 设置权限，使用 “-” 用于取消</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line">ls -lh 显示权限</span><br><span class="line">ls &#x2F;tmp | pr -T5 -W$COLUMNS 将终端划分成5栏显示</span><br><span class="line">chmod ugo+rwx directory1 设置目录的所有人(u)、群组(g)以及其他人(o)以读（r ）、写(w)和执行(x)的权限</span><br><span class="line">chmod go-rwx directory1 删除群组(g)与其他人(o)对目录的读写执行权限</span><br><span class="line">chown user1 file1 改变一个文件的所有人属性</span><br><span class="line">chown -R user1 directory1 改变一个目录的所有人属性并同时改变改目录下所有文件的属性</span><br><span class="line">chgrp group1 file1 改变文件的群组</span><br><span class="line">chown user1:group1 file1 改变一个文件的所有人和群组属性</span><br><span class="line">find &#x2F; -perm -u+s 罗列一个系统中所有使用了SUID控制的文件</span><br><span class="line">chmod u+s &#x2F;bin&#x2F;file1 设置一个二进制文件的 SUID 位 - 运行该文件的用户也被赋予和所有者同样的权限</span><br><span class="line">chmod u-s &#x2F;bin&#x2F;file1 禁用一个二进制文件的 SUID位</span><br><span class="line">chmod g+s &#x2F;home&#x2F;public 设置一个目录的SGID 位 - 类似SUID ，不过这是针对目录的</span><br><span class="line">chmod g-s &#x2F;home&#x2F;public 禁用一个目录的 SGID 位</span><br><span class="line">chmod o+t &#x2F;home&#x2F;public 设置一个文件的 STIKY 位 - 只允许合法所有人删除文件</span><br><span class="line">chmod o-t &#x2F;home&#x2F;public 禁用一个目录的 STIKY 位</span><br><span class="line">chmod +x 文件路径  为所有者、所属组和其他用户添加执行的权限</span><br><span class="line">chmod -x 文件路径  为所有者、所属组和其他用户删除执行的权限</span><br><span class="line">chmod u+x 文件路径  为所有者添加执行的权限</span><br><span class="line">chmod g+x 文件路径  为所属组添加执行的权限</span><br><span class="line">chmod o+x 文件路径  为其他用户添加执行的权限</span><br><span class="line">chmod ug+x 文件路径  为所有者、所属组添加执行的权限</span><br><span class="line">chmod &#x3D;wx 文件路径  为所有者、所属组和其他用户添加写、执行的权限，取消读权限</span><br><span class="line">chmod ug&#x3D;wx 文件路径  为所有者、所属组添加写、执行的权限，取消读权限</span><br></pre></td></tr></table></figure>
<h2 id="文件的特殊属性-使用-“-”-设置权限，使用-“-”-用于取消"><a href="#文件的特殊属性-使用-“-”-设置权限，使用-“-”-用于取消" class="headerlink" title="文件的特殊属性 - 使用 “+” 设置权限，使用 “-” 用于取消"></a>文件的特殊属性 - 使用 “+” 设置权限，使用 “-” 用于取消</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">chattr +a file1 只允许以追加方式读写文件</span><br><span class="line">chattr +c file1 允许这个文件能被内核自动压缩&#x2F;解压</span><br><span class="line">chattr +d file1 在进行文件系统备份时，dump程序将忽略这个文件</span><br><span class="line">chattr +i file1 设置成不可变的文件，不能被删除、修改、重命名或者链接</span><br><span class="line">chattr +s file1 允许一个文件被安全地删除</span><br><span class="line">chattr +S file1 一旦应用程序对这个文件执行了写操作，使系统立刻把修改的结果写到磁盘</span><br><span class="line">chattr +u file1 若文件被删除，系统会允许你在以后恢复这个被删除的文件</span><br><span class="line">lsattr 显示特殊的属性</span><br></pre></td></tr></table></figure>
<h2 id="打包和压缩文件"><a href="#打包和压缩文件" class="headerlink" title="打包和压缩文件"></a>打包和压缩文件</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line">bunzip2 file1.bz2 解压一个叫做 &#39;file1.bz2&#39;的文件</span><br><span class="line">bzip2 file1 压缩一个叫做 &#39;file1&#39; 的文件</span><br><span class="line">gunzip file1.gz 解压一个叫做 &#39;file1.gz&#39;的文件</span><br><span class="line">gzip file1 压缩一个叫做 &#39;file1&#39;的文件</span><br><span class="line">gzip -9 file1 最大程度压缩</span><br><span class="line">rar a file1.rar test_file 创建一个叫做 &#39;file1.rar&#39; 的包</span><br><span class="line">rar a file1.rar file1 file2 dir1 同时压缩 &#39;file1&#39;, &#39;file2&#39; 以及目录 &#39;dir1&#39;</span><br><span class="line">rar x file1.rar 解压rar包</span><br><span class="line">unrar x file1.rar 解压rar包</span><br><span class="line">tar -cvf archive.tar file1 创建一个非压缩的 tarball</span><br><span class="line">tar -cvf archive.tar file1 file2 dir1 创建一个包含了 &#39;file1&#39;, &#39;file2&#39; 以及 &#39;dir1&#39;的档案文件</span><br><span class="line">tar -tf archive.tar 显示一个包中的内容</span><br><span class="line">tar -xvf archive.tar 释放一个包</span><br><span class="line">tar -xvf archive.tar -C &#x2F;tmp 将压缩包释放到 &#x2F;tmp目录下</span><br><span class="line">tar -cvfj archive.tar.bz2 dir1 创建一个bzip2格式的压缩包</span><br><span class="line">tar -xvfj archive.tar.bz2 解压一个bzip2格式的压缩包</span><br><span class="line">tar -cvfz archive.tar.gz dir1 创建一个gzip格式的压缩包</span><br><span class="line">tar -xvfz archive.tar.gz 解压一个gzip格式的压缩包</span><br><span class="line">zip file1.zip file1 创建一个zip格式的压缩包</span><br><span class="line">zip -r file1.zip file1 file2 dir1 将几个文件和目录同时压缩成一个zip格式的压缩包</span><br><span class="line">unzip file1.zip 解压一个zip格式压缩包</span><br></pre></td></tr></table></figure>
<h2 id="RPM-包-（Fedora-Redhat及类似系统）"><a href="#RPM-包-（Fedora-Redhat及类似系统）" class="headerlink" title="RPM 包 - （Fedora, Redhat及类似系统）"></a>RPM 包 - （Fedora, Redhat及类似系统）</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line">rpm -ivh package.rpm 安装一个rpm包</span><br><span class="line">rpm -ivh --nodeeps package.rpm 安装一个rpm包而忽略依赖关系警告</span><br><span class="line">rpm -U package.rpm 更新一个rpm包但不改变其配置文件</span><br><span class="line">rpm -F package.rpm 更新一个确定已经安装的rpm包</span><br><span class="line">rpm -e package_name.rpm 删除一个rpm包</span><br><span class="line">rpm -qa 显示系统中所有已经安装的rpm包</span><br><span class="line">rpm -qa | grep httpd 显示所有名称中包含 &quot;httpd&quot; 字样的rpm包</span><br><span class="line">rpm -qi package_name 获取一个已安装包的特殊信息</span><br><span class="line">rpm -qg &quot;System Environment&#x2F;Daemons&quot; 显示一个组件的rpm包</span><br><span class="line">rpm -ql package_name 显示一个已经安装的rpm包提供的文件列表</span><br><span class="line">rpm -qc package_name 显示一个已经安装的rpm包提供的配置文件列表</span><br><span class="line">rpm -q package_name --whatrequires 显示与一个rpm包存在依赖关系的列表</span><br><span class="line">rpm -q package_name --whatprovides 显示一个rpm包所占的体积</span><br><span class="line">rpm -q package_name --scripts 显示在安装&#x2F;删除期间所执行的脚本l</span><br><span class="line">rpm -q package_name --changelog 显示一个rpm包的修改历史</span><br><span class="line">rpm -qf &#x2F;etc&#x2F;httpd&#x2F;conf&#x2F;httpd.conf 确认所给的文件由哪个rpm包所提供</span><br><span class="line">rpm -qp package.rpm -l 显示由一个尚未安装的rpm包提供的文件列表</span><br><span class="line">rpm --import &#x2F;media&#x2F;cdrom&#x2F;RPM-GPG-KEY 导入公钥数字证书</span><br><span class="line">rpm --checksig package.rpm 确认一个rpm包的完整性</span><br><span class="line">rpm -qa gpg-pubkey 确认已安装的所有rpm包的完整性</span><br><span class="line">rpm -V package_name 检查文件尺寸、 许可、类型、所有者、群组、MD5检查以及最后修改时间</span><br><span class="line">rpm -Va 检查系统中所有已安装的rpm包- 小心使用</span><br><span class="line">rpm -Vp package.rpm 确认一个rpm包还未安装</span><br><span class="line">rpm2cpio package.rpm | cpio --extract --make-directories *bin* 从一个rpm包运行可执行文件</span><br><span class="line">rpm -ivh &#x2F;usr&#x2F;src&#x2F;redhat&#x2F;RPMS&#x2F;&#96;arch&#96;&#x2F;package.rpm 从一个rpm源码安装一个构建好的包</span><br><span class="line">rpmbuild --rebuild package_name.src.rpm 从一个rpm源码构建一个 rpm 包</span><br></pre></td></tr></table></figure>
<h2 id="YUM-软件包升级器-（Fedora-RedHat及类似系统）"><a href="#YUM-软件包升级器-（Fedora-RedHat及类似系统）" class="headerlink" title="YUM 软件包升级器 - （Fedora, RedHat及类似系统）"></a>YUM 软件包升级器 - （Fedora, RedHat及类似系统）</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">yum install package_name 下载并安装一个rpm包</span><br><span class="line">yum localinstall package_name.rpm 将安装一个rpm包，使用你自己的软件仓库为你解决所有依赖关系</span><br><span class="line">yum update package_name.rpm 更新当前系统中所有安装的rpm包</span><br><span class="line">yum update package_name 更新一个rpm包</span><br><span class="line">yum remove package_name 删除一个rpm包</span><br><span class="line">yum list 列出当前系统中安装的所有包</span><br><span class="line">yum search package_name 在rpm仓库中搜寻软件包</span><br><span class="line">yum clean packages 清理rpm缓存删除下载的包</span><br><span class="line">yum clean headers 删除所有头文件</span><br><span class="line">yum clean all 删除所有缓存的包和头文件</span><br></pre></td></tr></table></figure>
<h2 id="DEB-包-Debian-Ubuntu-以及类似系统"><a href="#DEB-包-Debian-Ubuntu-以及类似系统" class="headerlink" title="DEB 包 (Debian, Ubuntu 以及类似系统)"></a>DEB 包 (Debian, Ubuntu 以及类似系统)</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">dpkg -i package.deb 安装&#x2F;更新一个 deb 包</span><br><span class="line">dpkg -r package_name 从系统删除一个 deb 包</span><br><span class="line">dpkg -l 显示系统中所有已经安装的 deb 包</span><br><span class="line">dpkg -l | grep httpd 显示所有名称中包含 &quot;httpd&quot; 字样的deb包</span><br><span class="line">dpkg -s package_name 获得已经安装在系统中一个特殊包的信息</span><br><span class="line">dpkg -L package_name 显示系统中已经安装的一个deb包所提供的文件列表</span><br><span class="line">dpkg --contents package.deb 显示尚未安装的一个包所提供的文件列表</span><br><span class="line">dpkg -S &#x2F;bin&#x2F;ping 确认所给的文件由哪个deb包提供</span><br><span class="line">APT 软件工具 (Debian, Ubuntu 以及类似系统)</span><br><span class="line">apt-get install package_name 安装&#x2F;更新一个 deb 包</span><br><span class="line">apt-cdrom install package_name 从光盘安装&#x2F;更新一个 deb 包</span><br><span class="line">apt-get update 升级列表中的软件包</span><br><span class="line">apt-get upgrade 升级所有已安装的软件</span><br><span class="line">apt-get remove package_name 从系统删除一个deb包</span><br><span class="line">apt-get check 确认依赖的软件仓库正确</span><br><span class="line">apt-get clean 从下载的软件包中清理缓存</span><br><span class="line">apt-cache search searched-package 返回包含所要搜索字符串的软件包名称</span><br></pre></td></tr></table></figure>
<h2 id="查看文件内容"><a href="#查看文件内容" class="headerlink" title="查看文件内容"></a>查看文件内容</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">cat file1 从第一个字节开始正向查看文件的内容</span><br><span class="line">tac file1 从最后一行开始反向查看一个文件的内容</span><br><span class="line">more file1 查看一个长文件的内容</span><br><span class="line">less file1 类似于 &#39;more&#39; 命令，但是它允许在文件中和正向操作一样的反向操作</span><br><span class="line">head -2 file1 查看一个文件的前两行</span><br><span class="line">tail -2 file1 查看一个文件的最后两行</span><br><span class="line">tail -f &#x2F;var&#x2F;log&#x2F;messages 实时查看被添加到一个文件中的内容</span><br></pre></td></tr></table></figure>
<h2 id="文本处理"><a href="#文本处理" class="headerlink" title="文本处理"></a>文本处理</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br></pre></td><td class="code"><pre><span class="line">cat file1 file2 ... | command &lt;&gt; file1_in.txt_or_file1_out.txt general syntax for text manipulation using PIPE, STDIN and STDOUT</span><br><span class="line">cat file1 | command( sed, grep, awk, grep, etc...) &gt; result.txt 合并一个文件的详细说明文本，并将简介写入一个新文件中</span><br><span class="line">cat file1 | command( sed, grep, awk, grep, etc...) &gt;&gt; result.txt 合并一个文件的详细说明文本，并将简介写入一个已有的文件中</span><br><span class="line">grep Aug &#x2F;var&#x2F;log&#x2F;messages 在文件 &#39;&#x2F;var&#x2F;log&#x2F;messages&#39;中查找关键词&quot;Aug&quot;</span><br><span class="line">grep ^Aug &#x2F;var&#x2F;log&#x2F;messages 在文件 &#39;&#x2F;var&#x2F;log&#x2F;messages&#39;中查找以&quot;Aug&quot;开始的词汇</span><br><span class="line">grep [0-9] &#x2F;var&#x2F;log&#x2F;messages 选择 &#39;&#x2F;var&#x2F;log&#x2F;messages&#39; 文件中所有包含数字的行</span><br><span class="line">grep Aug -R &#x2F;var&#x2F;log&#x2F;* 在目录 &#39;&#x2F;var&#x2F;log&#39; 及随后的目录中搜索字符串&quot;Aug&quot;</span><br><span class="line">sed &#39;s&#x2F;stringa1&#x2F;stringa2&#x2F;g&#39; example.txt 将example.txt文件中的 &quot;string1&quot; 替换成 &quot;string2&quot;</span><br><span class="line">sed &#39;&#x2F;^$&#x2F;d&#39; example.txt 从example.txt文件中删除所有空白行</span><br><span class="line">sed &#39;&#x2F; *#&#x2F;d; &#x2F;^$&#x2F;d&#39; example.txt 从example.txt文件中删除所有注释和空白行</span><br><span class="line">echo &#39;esempio&#39; | tr &#39;[:lower:]&#39; &#39;[:upper:]&#39; 合并上下单元格内容</span><br><span class="line">sed -e &#39;1d&#39; result.txt 从文件example.txt 中排除第一行</span><br><span class="line">sed -n &#39;&#x2F;stringa1&#x2F;p&#39; 查看只包含词汇 &quot;string1&quot;的行</span><br><span class="line">sed -e &#39;s&#x2F; *$&#x2F;&#x2F;&#39; example.txt 删除每一行最后的空白字符</span><br><span class="line">sed -e &#39;s&#x2F;stringa1&#x2F;&#x2F;g&#39; example.txt 从文档中只删除词汇 &quot;string1&quot; 并保留剩余全部</span><br><span class="line">sed -n &#39;1,5p;5q&#39; example.txt 查看从第一行到第5行内容</span><br><span class="line">sed -n &#39;5p;5q&#39; example.txt 查看第5行</span><br><span class="line">sed -e &#39;s&#x2F;00*&#x2F;0&#x2F;g&#39; example.txt 用单个零替换多个零</span><br><span class="line">cat -n file1 标示文件的行数</span><br><span class="line">cat example.txt | awk &#39;NR%2&#x3D;&#x3D;1&#39; 删除example.txt文件中的所有偶数行</span><br><span class="line">echo a b c | awk &#39;&#123;print $1&#125;&#39; 查看一行第一栏</span><br><span class="line">echo a b c | awk &#39;&#123;print $1,$3&#125;&#39; 查看一行的第一和第三栏</span><br><span class="line">paste file1 file2 合并两个文件或两栏的内容</span><br><span class="line">paste -d &#39;+&#39; file1 file2 合并两个文件或两栏的内容，中间用&quot;+&quot;区分</span><br><span class="line">sort file1 file2 排序两个文件的内容</span><br><span class="line">sort file1 file2 | uniq 取出两个文件的并集(重复的行只保留一份)</span><br><span class="line">sort file1 file2 | uniq -u 删除交集，留下其他的行</span><br><span class="line">sort file1 file2 | uniq -d 取出两个文件的交集(只留下同时存在于两个文件中的文件)</span><br><span class="line">comm -1 file1 file2 比较两个文件的内容只删除 &#39;file1&#39; 所包含的内容</span><br><span class="line">comm -2 file1 file2 比较两个文件的内容只删除 &#39;file2&#39; 所包含的内容</span><br><span class="line">comm -3 file1 file2 比较两个文件的内容只删除两个文件共有的部分</span><br></pre></td></tr></table></figure>
<h2 id="字符设置和文件格式转换"><a href="#字符设置和文件格式转换" class="headerlink" title="字符设置和文件格式转换"></a>字符设置和文件格式转换</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">dos2unix filedos.txt fileunix.txt 将一个文本文件的格式从MSDOS转换成UNIX</span><br><span class="line">unix2dos fileunix.txt filedos.txt 将一个文本文件的格式从UNIX转换成MSDOS</span><br><span class="line">recode ..HTML &lt; page.txt &gt; page.html 将一个文本文件转换成html</span><br><span class="line">recode -l | more 显示所有允许的转换格式</span><br></pre></td></tr></table></figure>
<h2 id="文件系统分析"><a href="#文件系统分析" class="headerlink" title="文件系统分析"></a>文件系统分析</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">badblocks -v &#x2F;dev&#x2F;hda1 检查磁盘hda1上的坏磁块</span><br><span class="line">fsck &#x2F;dev&#x2F;hda1 修复&#x2F;检查hda1磁盘上linux文件系统的完整性</span><br><span class="line">fsck.ext2 &#x2F;dev&#x2F;hda1 修复&#x2F;检查hda1磁盘上ext2文件系统的完整性</span><br><span class="line">e2fsck &#x2F;dev&#x2F;hda1 修复&#x2F;检查hda1磁盘上ext2文件系统的完整性</span><br><span class="line">e2fsck -j &#x2F;dev&#x2F;hda1 修复&#x2F;检查hda1磁盘上ext3文件系统的完整性</span><br><span class="line">fsck.ext3 &#x2F;dev&#x2F;hda1 修复&#x2F;检查hda1磁盘上ext3文件系统的完整性</span><br><span class="line">fsck.vfat &#x2F;dev&#x2F;hda1 修复&#x2F;检查hda1磁盘上fat文件系统的完整性</span><br><span class="line">fsck.msdos &#x2F;dev&#x2F;hda1 修复&#x2F;检查hda1磁盘上dos文件系统的完整性</span><br><span class="line">dosfsck &#x2F;dev&#x2F;hda1 修复&#x2F;检查hda1磁盘上dos文件系统的完整性</span><br></pre></td></tr></table></figure>
<h2 id="初始化一个文件系统"><a href="#初始化一个文件系统" class="headerlink" title="初始化一个文件系统"></a>初始化一个文件系统</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">mkfs &#x2F;dev&#x2F;hda1 在hda1分区创建一个文件系统</span><br><span class="line">mke2fs &#x2F;dev&#x2F;hda1 在hda1分区创建一个linux ext2的文件系统</span><br><span class="line">mke2fs -j &#x2F;dev&#x2F;hda1 在hda1分区创建一个linux ext3(日志型)的文件系统</span><br><span class="line">mkfs -t vfat 32 -F &#x2F;dev&#x2F;hda1 创建一个 FAT32 文件系统</span><br><span class="line">fdformat -n &#x2F;dev&#x2F;fd0 格式化一个软盘</span><br><span class="line">mkswap &#x2F;dev&#x2F;hda3 创建一个swap文件系统</span><br></pre></td></tr></table></figure>
<h2 id="SWAP文件系统"><a href="#SWAP文件系统" class="headerlink" title="SWAP文件系统"></a>SWAP文件系统</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">mkswap &#x2F;dev&#x2F;hda3 创建一个swap文件系统</span><br><span class="line">swapon &#x2F;dev&#x2F;hda3 启用一个新的swap文件系统</span><br><span class="line">swapon &#x2F;dev&#x2F;hda2 &#x2F;dev&#x2F;hdb3 启用两个swap分区</span><br></pre></td></tr></table></figure>
<h2 id="备份"><a href="#备份" class="headerlink" title="备份"></a>备份</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">dump -0aj -f &#x2F;tmp&#x2F;home0.bak &#x2F;home 制作一个 &#39;&#x2F;home&#39; 目录的完整备份</span><br><span class="line">dump -1aj -f &#x2F;tmp&#x2F;home0.bak &#x2F;home 制作一个 &#39;&#x2F;home&#39; 目录的交互式备份</span><br><span class="line">restore -if &#x2F;tmp&#x2F;home0.bak 还原一个交互式备份</span><br><span class="line">rsync -rogpav --delete &#x2F;home &#x2F;tmp 同步两边的目录</span><br><span class="line">rsync -rogpav -e ssh --delete &#x2F;home ip_address:&#x2F;tmp 通过SSH通道rsync</span><br><span class="line">rsync -az -e ssh --delete ip_addr:&#x2F;home&#x2F;public &#x2F;home&#x2F;local 通过ssh和压缩将一个远程目录同步到本地目录</span><br><span class="line">rsync -az -e ssh --delete &#x2F;home&#x2F;local ip_addr:&#x2F;home&#x2F;public 通过ssh和压缩将本地目录同步到远程目录</span><br><span class="line">dd bs&#x3D;1M if&#x3D;&#x2F;dev&#x2F;hda | gzip | ssh user@ip_addr &#39;dd of&#x3D;hda.gz&#39; 通过ssh在远程主机上执行一次备份本地磁盘的操作</span><br><span class="line">dd if&#x3D;&#x2F;dev&#x2F;sda of&#x3D;&#x2F;tmp&#x2F;file1 备份磁盘内容到一个文件</span><br><span class="line">tar -Puf backup.tar &#x2F;home&#x2F;user 执行一次对 &#39;&#x2F;home&#x2F;user&#39; 目录的交互式备份操作</span><br><span class="line">( cd &#x2F;tmp&#x2F;local&#x2F; &amp;&amp; tar c . ) | ssh -C user@ip_addr &#39;cd &#x2F;home&#x2F;share&#x2F; &amp;&amp; tar x -p&#39; 通过ssh在远程目录中复制一个目录内容</span><br><span class="line">( tar c &#x2F;home ) | ssh -C user@ip_addr &#39;cd &#x2F;home&#x2F;backup-home &amp;&amp; tar x -p&#39; 通过ssh在远程目录中复制一个本地目录</span><br><span class="line">tar cf - . | (cd &#x2F;tmp&#x2F;backup ; tar xf - ) 本地将一个目录复制到另一个地方，保留原有权限及链接</span><br><span class="line">find &#x2F;home&#x2F;user1 -name &#39;*.txt&#39; | xargs cp -av --target-directory&#x3D;&#x2F;home&#x2F;backup&#x2F; --parents 从一个目录查找并复制所有以 &#39;.txt&#39; 结尾的文件到另一个目录</span><br><span class="line">find &#x2F;var&#x2F;log -name &#39;*.log&#39; | tar cv --files-from&#x3D;- | bzip2 &gt; log.tar.bz2 查找所有以 &#39;.log&#39; 结尾的文件并做成一个bzip包</span><br><span class="line">dd if&#x3D;&#x2F;dev&#x2F;hda of&#x3D;&#x2F;dev&#x2F;fd0 bs&#x3D;512 count&#x3D;1 做一个将 MBR (Master Boot Record)内容复制到软盘的动作</span><br><span class="line">dd if&#x3D;&#x2F;dev&#x2F;fd0 of&#x3D;&#x2F;dev&#x2F;hda bs&#x3D;512 count&#x3D;1 从已经保存到软盘的备份中恢复MBR内容</span><br></pre></td></tr></table></figure>
<h2 id="网络-（以太网和WIFI无线）"><a href="#网络-（以太网和WIFI无线）" class="headerlink" title="网络 - （以太网和WIFI无线）"></a>网络 - （以太网和WIFI无线）</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line">ifconfig eth0 显示一个以太网卡的配置</span><br><span class="line">ifup eth0 启用一个 &#39;eth0&#39; 网络设备</span><br><span class="line">ifdown eth0 禁用一个 &#39;eth0&#39; 网络设备</span><br><span class="line">ifconfig eth0 192.168.1.1 netmask 255.255.255.0 控制IP地址</span><br><span class="line">ifconfig eth0 promisc 设置 &#39;eth0&#39; 成混杂模式以嗅探数据包 (sniffing)</span><br><span class="line">dhclient eth0 以dhcp模式启用 &#39;eth0&#39;</span><br><span class="line">route -n show routing table</span><br><span class="line">route add -net 0&#x2F;0 gw IP_Gateway configura default gateway</span><br><span class="line">route add -net 192.168.0.0 netmask 255.255.0.0 gw 192.168.1.1 configure static route to reach network &#39;192.168.0.0&#x2F;16&#39;</span><br><span class="line">route del 0&#x2F;0 gw IP_gateway remove static route</span><br><span class="line">echo &quot;1&quot; &gt; &#x2F;proc&#x2F;sys&#x2F;net&#x2F;ipv4&#x2F;ip_forward activate ip routing</span><br><span class="line">hostname show hostname of system</span><br><span class="line">host www.example.com lookup hostname to resolve name to ip address and viceversa(1)</span><br><span class="line">nslookup www.example.com lookup hostname to resolve name to ip address and viceversa(2)</span><br><span class="line">ip link show show link status of all interfaces</span><br><span class="line">mii-tool eth0 show link status of &#39;eth0&#39;</span><br><span class="line">ethtool eth0 show statistics of network card &#39;eth0&#39;</span><br><span class="line">netstat -tup show all active network connections and their PID</span><br><span class="line">netstat -tupl show all network services listening on the system and their PID</span><br><span class="line">tcpdump tcp port 80 show all HTTP traffic</span><br><span class="line">iwlist scan show wireless networks</span><br><span class="line">iwconfig eth1 show configuration of a wireless network card</span><br><span class="line">hostname show hostname</span><br><span class="line">host www.example.com lookup hostname to resolve name to ip address and viceversa</span><br><span class="line">nslookup www.example.com lookup hostname to resolve name to ip address and viceversa</span><br><span class="line">whois www.example.com lookup on Whois database</span><br></pre></td></tr></table></figure>
<h2 id="列出目录内容"><a href="#列出目录内容" class="headerlink" title="列出目录内容"></a>列出目录内容</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">ls -a：显示所有文件（包括隐藏文件);</span><br><span class="line">ls -l：显示详细信息；</span><br><span class="line">ls -R：递归显示子目录结构；</span><br><span class="line">ls -ld：显示目录和链接信息；</span><br><span class="line">ctrl+r：历史记录中所搜命令（输入命令中的任意一个字符）；</span><br><span class="line">Linux中以.开头的文件是隐藏文件；</span><br><span class="line">pwd:显示当前目录</span><br></pre></td></tr></table></figure>
<h2 id="查看文件的类型"><a href="#查看文件的类型" class="headerlink" title="查看文件的类型"></a>查看文件的类型</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">file:查看文件的类型</span><br></pre></td></tr></table></figure>
<h2 id="复制文件目录"><a href="#复制文件目录" class="headerlink" title="复制文件目录"></a>复制文件目录</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br></pre></td><td class="code"><pre><span class="line">1、cp：复制文件和目录 cp源文件（文件夹）目标文件（文件夹）</span><br><span class="line">常用参数：-r:递归复制整个目录树；-v：显示详细信息；</span><br><span class="line">复制文件夹时要在cp命令后面加一个-r参数：</span><br><span class="line">如：cp -r 源文件夹  目标文件夹</span><br><span class="line"></span><br><span class="line">2、touch+文件名：当文件不存在的时候，创建相应的文件；当文件存在的时候，修改文件的创建时间。</span><br><span class="line">功能：生成一个空文件或修改文件的存取&#x2F;修改的时间记录值。</span><br><span class="line">touch * ：将当前下的文件时间修改为系统的当前时间</span><br><span class="line">touch –d 20040210 test：将test文件的日期改为20040210</span><br><span class="line">touch abc　：若abc文件存在，则修改为系统的当前时间；若不存在，则生成一个为当前时间的空文件</span><br><span class="line"></span><br><span class="line">3、mv 文件 目标目录：移动或重命名文件或目录（如果指定文件名，则可以重命名文件）。可以将文件及目录移到另一目录下，或更改文件及目录的名称。</span><br><span class="line">格式为：mv [参数]&lt;源文件或目录&gt; &lt;目标文件或目录&gt;</span><br><span class="line">mva.txt ..&#x2F;：将a.txt文件移动上层目录</span><br><span class="line">mv a.txt b.txt：将a.txt改名为b.txt</span><br><span class="line">mvdir2 ..&#x2F;：将dir2目录上移一层</span><br><span class="line">4、rm：删除文件；</span><br><span class="line">常用参数：-i：交互式   -r：递归的删除包括目录中的所有内容</span><br><span class="line">5、mkdir +文件夹名称：创建文件夹；</span><br><span class="line">6、rm -r +文件夹名称：删除文件夹（空文件夹和非空文件夹都可删除）</span><br><span class="line">rmdir 文件夹名称：删除文件夹（只能删除空文件夹）</span><br><span class="line">7、mkdir  -p dir1&#x2F;dir2 ：在当前目录下创建dir1目录，并在dir1目录下创建dir2目录， 也就是连续创建两个目录（dir1&#x2F;和dir1&#x2F;dir2）</span><br><span class="line">8、rmdir –p dir1&#x2F;dir2：删除dir1下的dir2目录，若dir1目录为空也删除它</span><br><span class="line">9、rm * ：删除当前目录下的所有文件</span><br><span class="line">10、-f参数：强迫删除文件 rm –f  *.txt：强迫删除所有以后缀名为txt文件</span><br><span class="line">11、-i参数：删除文件时询问</span><br><span class="line">rm　–i  * ：删除当前目录下的所有文件会有如下提示：</span><br><span class="line">rm:backup:is a directory　　　 遇到目录会略过</span><br><span class="line">rm: remove ‘myfiles.txt’ ? Y</span><br><span class="line">删除文件时会询问,可按Y或N键表示允许或拒绝删除文件　</span><br><span class="line">12、-r参数：递归删除（连子目录一同删除，这是一个相当常用的参数）</span><br><span class="line">rm  -r test ：删除test目录（含test目录下所有文件和子目录）</span><br><span class="line">rm  -r  *：删除所有文件（含当前目录所有文件、所有子目录和子目录下的文件） 一般在删除目录时r和f一起用，避免麻烦</span><br><span class="line">rm  -rf test ：强行删除、不加询问</span><br><span class="line">13、grep：功能：在文件中搜索匹配的字符并进行输出</span><br><span class="line">格式：grep[参数] &lt;要找的字串&gt; &lt;要寻找字 串的源文件&gt;</span><br><span class="line">greplinux test.txt：搜索test.txt文件中字符串linux并输出</span><br><span class="line">14、ln命令</span><br><span class="line">功能：在文件和目录之间建立链接</span><br><span class="line">格式：ln [参数] &lt;源文件或目录&gt; &lt;目标文件或目录&gt;</span><br><span class="line">链接分“软链接”和“硬链接”</span><br><span class="line">1.软链接:</span><br><span class="line">ln–s &#x2F;usr&#x2F;share&#x2F;do  doc ：创建一个链接文件doc,并指向目录&#x2F;usr&#x2F;share&#x2F;do</span><br><span class="line">2.硬链接:</span><br><span class="line">ln  &#x2F;usr&#x2F;share&#x2F;test  hard：创建一个硬链接文件hard，这时对于test文件对应 的存储区域来说，又多了一个文件指向它</span><br></pre></td></tr></table></figure>
<h2 id="系统常用命令"><a href="#系统常用命令" class="headerlink" title="系统常用命令"></a>系统常用命令</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br></pre></td><td class="code"><pre><span class="line">1、显示命令</span><br><span class="line">date:查看或设置当前系统的时间：格式化显示时间：+%Y--%m--%d；</span><br><span class="line">date -s:设置当前系统的时间</span><br><span class="line">hwclock(clock)：显示硬件时钟时间(需要管理员权限)；</span><br><span class="line">cal：查看日历</span><br><span class="line">格式cal [参数] 月年</span><br><span class="line">cal：显示当月的日历   cal4 2004 ：显示2004年4月的日历</span><br><span class="line">cal- y 2003： 显示2003年的日历</span><br><span class="line">uptime：查看系统运行时间</span><br><span class="line">2、输出查看命令</span><br><span class="line">echo：显示输入的内容  追加文件echo &quot;liuyazhuang&quot; &gt;&gt; liuyazhuang.txt</span><br><span class="line">cat：显示文件内容,也可以将数个文件合并成一个文件。</span><br><span class="line">格式：格式：cat[参数]&lt;文件名&gt;</span><br><span class="line">cat  test.txt：显示test.txt文件内容</span><br><span class="line">cat  test.txt | more  ：逐页显示test.txt文件中的内容</span><br><span class="line">cat  test.txt &gt;&gt; test1.txt ：将test.txt的内容附加到test1.txt文件之后</span><br><span class="line">cat  test.txt test2.txt &gt;readme.txt　: 将test.txt和test2.txt文件合并成readme.txt 文件</span><br><span class="line">head:显示文件的头几行（默认10行） -n:指定显示的行数格式：head -n 文件名</span><br><span class="line">tail：显示文件的末尾几行（默认10行）-n：指定显示的行数   -f：追踪显示文件更新 （一般用于查看日志，命令不会退出，而是持续显示新加入的内容）</span><br><span class="line">格式：格式：tail[参数]&lt;文件名&gt;</span><br><span class="line">tail-10 &#x2F;etc&#x2F;passwd ：显示&#x2F;etc&#x2F;passwd&#x2F;文件的倒数10行内容</span><br><span class="line">tail+10 &#x2F;etc&#x2F;passwd ：显示&#x2F;etc&#x2F;passwd&#x2F;文件从第10行开始到末尾的内容</span><br><span class="line">more：用于翻页显示文件内容（只能向下翻页）</span><br><span class="line">more命令是一般用于要显示的内容会超过一个画面长度的情况。为了避免画  面显示时瞬间就闪过去，用户可以使用more命令，让画面在显示满一页时暂停，此时可按空格健继续显示下一个画面，或按Q键停止显示。</span><br><span class="line">ls  -al  |more：以长格形式显示etc目录下的文件列表，显示满一个画面便暂停，可 按空格键继续显示下一画面，或按Q键跳离</span><br><span class="line">less：翻页显示文件内容（带上下翻页）按下上键分页，按q退出、‘</span><br><span class="line">less命令的用法与more命令类似，也可以用来浏览超过一页的文件。所不同  的是less 命令除了可以按空格键向下显示文件外，还可以利用上下键来卷动文件。当要结束浏览时，只要在less命令的提示符“：”下按Q键即可。</span><br><span class="line">ls  -al | less：以长格形式列出&#x2F;etc目录中所有的内容。用户可按上下键浏览或按Q键跳离</span><br><span class="line">3、查看硬件信息</span><br><span class="line">Ispci：查看PCI设备  -v：查看详细信息</span><br><span class="line">Isusb：查看USB设备 -v：查看详细信息</span><br><span class="line">Ismod：查看加载的模块(驱动)</span><br><span class="line">4、关机、重启</span><br><span class="line">shutdown关闭、重启计算机</span><br><span class="line">shutdown[关机、重启]时间  -h关闭计算机   -r：重启计算机</span><br><span class="line">如：立即关机： shutdown -h now</span><br><span class="line">10分钟后关机：shutdown -h +10</span><br><span class="line">23:30分关机：shutdown -h 23:30</span><br><span class="line">立即重启： shutdown -r now</span><br><span class="line">poweroff：立即关闭计算机</span><br><span class="line">reboot：立即重启计算机</span><br><span class="line">5、归档、压缩</span><br><span class="line">zip:压缩文件  zip liuyazhuang.zip myfile  格式为：“zip 压缩后的zip文件文件名”</span><br><span class="line">unzip：解压文件  unzip liuyazhuang.zip</span><br><span class="line">gzip：压缩文件 gzip 文件名</span><br><span class="line">tar：归档文件</span><br><span class="line">tar -cvf out.tar liuyazhuang  打包一个归档（将文件&quot;liuyazhuang&quot;打包成一个归档）</span><br><span class="line">tar -xvf liuyazhuang.tar     释放一个归档（释放liuyazhuang.tar归档）</span><br><span class="line">tar -cvzf backup.tar.gz&#x2F;etc  </span><br><span class="line">-z参数将归档后的归档文件进行gzip压缩以减少大小。</span><br><span class="line">-c：创建一个新tar文件</span><br><span class="line">-v：显示运行过程的信息</span><br><span class="line">-f：指定文件名</span><br><span class="line">-z：调用gzip压缩命令进行压缩</span><br><span class="line">-t：查看压缩文件的内容</span><br><span class="line">-x：解开tar文件</span><br><span class="line">tar  -cvf test.tar  *：将所有文件打包成test.tar,扩展名.tar需自行加上</span><br><span class="line">tar  -zcvf test.tar.gz  *：将所有文件打包成test.tar,再用gzip命令压缩</span><br><span class="line">tar -tf   test.tar ：查看test.tar文件中包括了哪些文件</span><br><span class="line">tar -xvf test.tar       将test.tar解开</span><br><span class="line">tar -zxvf foo.tar.gz   解压缩</span><br><span class="line">gzip各gunzip命令</span><br><span class="line">gziptest.txt ：压缩文件时，不需要任何参数</span><br><span class="line">gizp–l test.txt.gz：显示压缩率</span><br><span class="line">6、查找</span><br><span class="line">locate：快速查找文件、文件夹： locate keyword</span><br><span class="line">此命令需要预先建立数据库，数据库默认每天更新一次，可用updatedb命令手工建立、更新数据库。</span><br><span class="line">find查找位置查找参数</span><br><span class="line">如：</span><br><span class="line">find . -name *liuyazhuang* 查找当前目录下名称中含有&quot;liuyazhuang&quot;的文件</span><br><span class="line">find &#x2F; -name *.conf  查找根目录下（整个硬盘）下后缀为.conf的文件</span><br><span class="line">find &#x2F; -perm 777 查找所有权限是777的文件</span><br><span class="line">find &#x2F; -type d 返回根目录下所有的目录</span><br><span class="line">find . -name &quot;a*&quot;-exec ls -l &#123;&#125; \;</span><br><span class="line">find功能：用来寻找文件或目录。</span><br><span class="line">格式：find [&lt;路径&gt;] [匹配条件]</span><br><span class="line">find &#x2F; -name httpd.conf  搜索系统根目录下名为httpd.conf的文件</span><br><span class="line">7、ctrl+c :终止当前的命令</span><br><span class="line">8、who或w命令</span><br><span class="line">功能：查看当前系统中有哪些用户登录</span><br><span class="line">格式：who&#x2F;w[参数]</span><br><span class="line">9、dmesg命令       功能：显示系统诊断信息、操作系统版本号、物理内存的大小以及其它信息</span><br><span class="line">10、df命令   功能：用于查看文件系统的各个分区的占用情况</span><br><span class="line">11、du命令</span><br><span class="line">功能：查看某个目录中各级子目录所使用的硬盘空间数</span><br><span class="line">格式：du [参数] &lt;目录名&gt;</span><br><span class="line">12、free命令</span><br><span class="line">功能：用于查看系统内存，虚拟内存（交换空间）的大小占用情况</span><br></pre></td></tr></table></figure>
<h2 id="VIM"><a href="#VIM" class="headerlink" title="VIM"></a>VIM</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><span class="line">VIM是一款功能强大的命令行文本编辑器，在Linux中通过vim命令可以启动vim编辑器。</span><br><span class="line">一般使用vim + 目标文件路径 的形式使用vim</span><br><span class="line">如果目标文件存在，则vim打开目标文件，如果目标文件不存在，则vim新建并打开该文件</span><br><span class="line">:q：退出vim编辑器</span><br><span class="line">VIM模式</span><br><span class="line">vim拥有三种模式</span><br><span class="line">（1）命令模式（常规模式）</span><br><span class="line">vim启动后，默认进入命令模式，任何模式都可以通过esc键回到命令模式（可以多按几次），命令模式下可以键入不同的命令完成选择、复制、粘贴、撤销等操作。</span><br><span class="line">命名模式常用命令如下：</span><br><span class="line">i : 在光标前插入文本；</span><br><span class="line">o:在当前行的下面插入新行；</span><br><span class="line">dd:删除整行；</span><br><span class="line">yy：将当前行的内容放入缓冲区（复制当前行）</span><br><span class="line">n+yy :将n行的内容放入缓冲区（复制n行）</span><br><span class="line">p:将缓冲区中的文本放入光标后（粘贴）</span><br><span class="line">u：撤销上一个操作</span><br><span class="line">r:替换当前字符</span><br><span class="line">&#x2F; 查找关键字</span><br><span class="line">（2）插入模式</span><br><span class="line">在命令模式下按 &quot; i &quot;键，即可进入插入模式，在插入模式可以输入编辑文本内容，使用esc键可以返回命令模式。</span><br><span class="line">（3）ex模式</span><br><span class="line">在命令模式中按&quot; : &quot;键可以进入ex模式，光标会移动到底部，在这里可以保存修改或退出vim.</span><br><span class="line">ext模式常用命令如下：</span><br><span class="line">:w ：保存当前的修改</span><br><span class="line">:q ：退出</span><br><span class="line">:q! ：强制退出，保存修改</span><br><span class="line">:x  :保存并退出，相当于:wq</span><br><span class="line">:set number 显示行号</span><br><span class="line">:! 系统命令  执行一个系统命令并显示结果</span><br><span class="line">:sh ：切换到命令行，使用ctrl+d切换回vim</span><br></pre></td></tr></table></figure>
<h2 id="软件包管理命令-RPM"><a href="#软件包管理命令-RPM" class="headerlink" title="软件包管理命令(RPM)"></a>软件包管理命令(RPM)</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line">1、软件包的安装</span><br><span class="line">使用RPM命令的安装模式可以将软件包内所有的组件放到系统中的正确路径，安装软件包的命令是:rpm –ivh wu-ftpd-2.6.2-8.i386.rpm</span><br><span class="line">i：作用rpm的安装模式 v: 校验文件信息h: 以＃号显示安装进度</span><br><span class="line">2、软件包的删除</span><br><span class="line">删除模式会将指定软件包的内容全部删除，但并不包括已更改过的配置文件，删除RPM软件包的命令如下：rpm –e  wu-ftpd</span><br><span class="line">注意：这里必须使用软件名“wu-ftpd”或”wu-ftpd-2.6.2-8而不是使用当初安装时的软件包名.wu-ftpd-2.6.2-8.i386.rpm</span><br><span class="line">3、软件包升级</span><br><span class="line">升级模式会安装用户所指定的更新版本，并删除已安装在系统中的相同软件包，升级软件包命令如下：rpm –Uvh wu-ftpd-2.6.2-8.i386.rpm  –Uvh：升级参数</span><br><span class="line">4、软件包更新</span><br><span class="line">更新模式下，rpm命令会检查在命令行中所指定的软件包是否比系统中原有的软件 包更新。如果情况属实，rpm命令会自动更新指定的软件包；反之，若系统中并没有指定软件包的较旧版本，rpm命令并不会安装此软件包。而在升级模式下，不管系统中是否有较旧的版本，rpm命令都会安装指定的软件包。</span><br><span class="line">rpm –Fvhwu-ftpd-2.6.2-8.i386.rpm   -Fvh：更新参数</span><br><span class="line">5、软件包查询</span><br><span class="line">若要获取RPM软件包的相关信息，可以使用查询模式。使用-q参数可查询一个已   安装的软件包的内容</span><br><span class="line">rpm  –q wu-ftpd</span><br><span class="line">查询软件包所安装的位置：rpm –ql package-name</span><br><span class="line">rpm –ql xv (l参数：显示文件列表)</span><br></pre></td></tr></table></figure>
<h2 id="Linux-Command"><a href="#Linux-Command" class="headerlink" title="Linux Command"></a>Linux Command</h2><img src="/2021/06/15/Linux-%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4/DSC_0174.JPG" class="" title="Linux Command">

    </div>

    
    
    

    <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/Linux/" rel="tag"># Linux</a>
          </div>

        

          <div class="post-nav">
            <div class="post-nav-item">
                <a href="/2021/05/11/%E8%BF%90%E5%8A%A8%E9%A3%9F%E8%B0%B1-%E7%AE%80%E7%89%88/" rel="prev" title="运动食谱-简版">
                  <i class="fa fa-chevron-left"></i> 运动食谱-简版
                </a>
            </div>
            <div class="post-nav-item">
            </div>
          </div>
    </footer>
  </article>
</div>





<script src="/js/comments.js"></script>
</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">


<div class="copyright">
  &copy; 
  <span itemprop="copyrightYear">2021</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">冰冷的火焰</span>
</div>
<div class="busuanzi-count">
    <span class="post-meta-item" id="busuanzi_container_site_uv">
      <span class="post-meta-item-icon">
        <i class="fa fa-user"></i>
      </span>
      <span class="site-uv" title="总访客量">
        <span id="busuanzi_value_site_uv"></span>
      </span>
    </span>
    <span class="post-meta-item" id="busuanzi_container_site_pv">
      <span class="post-meta-item-icon">
        <i class="fa fa-eye"></i>
      </span>
      <span class="site-pv" title="总访问量">
        <span id="busuanzi_value_site_pv"></span>
      </span>
    </span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://theme-next.js.org/" class="theme-link" rel="noopener" target="_blank">NexT.Gemini</a> 强力驱动
  </div>

    </div>
  </footer>

  
  <script src="https://cdn.jsdelivr.net/npm/animejs@3.2.1/lib/anime.min.js"></script>
<script src="/js/utils.js"></script><script src="/js/motion.js"></script><script src="/js/next-boot.js"></script>

  






  
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>





</body>
</html>
